package com.yuanzong.wuliu.controller.intercdeptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class WebSecurityConfig implements WebMvcConfigurer {

    @Resource
    private AdminHandlerInterceptorAdapter myHandlerInterceptorAdapter;
    @Resource
    private AppHandlerInterceptorAdapter appHandlerInterceptorAdapter;

    /**
     * 配置拦截器
     *
     * @param registry 相当于拦截器的注册中心
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myHandlerInterceptorAdapter)
                //拦截所有admin
                .addPathPatterns("/admin/**")
                .order(1);
        registry.addInterceptor(appHandlerInterceptorAdapter)
                //拦截所有app
                .addPathPatterns("/app/**")
                .order(2);
    }

}
